﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Wizard.UI;

namespace AppScan
{
    public partial class TypePage : InternalWizardPage
    {
        private readonly CreateExportContext _context;
        string filename = string.Empty;

        public TypePage(CreateExportContext context)
        {
            _context = context;
            InitializeComponent();
        }

        private void TypePage_Load(object sender, EventArgs e)
        {

        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            _context.xml = checkBox1.Checked;
            _context.csv = checkBox2.Checked;
            _context.pdf = checkBox3.Checked;
            _context.html = checkBox4.Checked;
            _context.executive = checkBox5.Checked;    
            EnableControls();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //save file dialog
            saveFileDialog1.ShowDialog();
        }

        private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            filename = saveFileDialog1.FileName;
            textBox1.Text = filename;
            EnableControls();
        }

        private void EnableControls()
        {
            bool nextEnabled = true;
            bool filetypeselect = false;

            if (String.IsNullOrEmpty(textBox1.Text))
                nextEnabled = false;

            foreach (Control ctl in this.Controls)
            {
                if (ctl.GetType() == typeof(CheckBox))
                {
                    if ((ctl as CheckBox).Checked)
                    {
                        filetypeselect = true;
                        break;
                    }
                }
            }


            if (nextEnabled && filetypeselect)
                SetWizardButtons(WizardButtons.Back | WizardButtons.Next);
            else
                SetWizardButtons(WizardButtons.Back);
        }

        private void TypePage_WizardNext(object sender, WizardPageEventArgs e)
        {

        }

        private void TypePage_WizardBack(object sender, WizardPageEventArgs e)
        {

        }


    }
}
